pp108 : Working with SOAP Requests and Responses

Working with SOAP Requests and Responses

This topic describes the SOAP requests and responses used by WS-AppServer.

Introduction


WS-AppServer is the business logic layer in Process Platform. It supports a standard set of SOAP requests that a SOAP client uses for XML messaging. It also defines a standard set of response formats that will return SOAP results as desired.
The following table lists the SOAP requests used in WS-AppServer.
Table 1. SOAP Requests

Request Purpose
Update Invoke the application logic to insert, update, and delete objects in the database. The execution of these actions depends upon the tuple status. This is illustrated in the following figure.
Note: In any update SOAP request, the XML attribute reply= 'yes|no' determines whether the response will contain the tuple or not. Specifying 'yes' will return the tuple in the SOAP response, whereas specifying 'no' will not return the tuple. However, if nothing is specified, the response will contain the tuple (as a result of default behaviour being reply= 'yes').
GetObject Invoke the application logic to retrieve objects from the database and display it on the user interface. For example, GetEmployeesObject , GetEmployeesObjects .
Validate Invoke the application logic to validate objects without saving them in the database.
Query Retrieve data from the database using a query.


The following table lists the different response types that are returned:
Table 2. SOAP Responses

Response Type Description Method Used
XML Response is in the form of an XML document. execute
Single java object Response is in the form of a single object. The class of the object that is returned can be specified using the setResultClass method. If you do not set the result class, an object of class AnonymousBusObject is returned. getObject
Collection of java objects Response is in the form of a collection of objects. The class of the objects that are returned can be specified using the setResultClass method. If you don't set the result class, objects of class AnonymousBusObject are returned. getObjects


Creating and Running a SOAP Request


In WS-AppServer, you can write logic to create a SOAP request and run it. You can set the response type to any of those described in Table 2.

The following sample code describes the creation of a SOAP request.

// make SOAP request String namespace = "http://schemas.cordys.com/NewAppServererver"; String methodName = "GetCustomersObject"; String customerID = "GREAL"; String\[\] paramNames = new String\[\]{"CustomerID"}; Object\[\] paramValues = new Object\[\]{customerID}; // execute SOAPRequestObject sro = new SOAPRequestObject(namespace, methodName, paramNames, paramValues); sro.setResultClass(Customers.class); Customers cust = (Customers)sro.getObject();


PARAMETERS OF THE SOAP REQUEST
The following table describes the two parameters used in the above example.
Table 3. Parameters of the SOAP Request

Parameter Description
paramNames Contains the name of the parameter.
paramValues Contains the values for the specified parameter names. The parameter values are defined based on the following specification:
Parameter Type Placement in the SOAP Request
BusObject As a tuple
BusObjectIterator As a collection of tuples
Any other type As a string representation (using toString )


Parameters for the SOAP request are passed as arguments to the constructor. The following code sample illustrates this statement:

SOAPRequestObject oReq = new SOAPRequestObject(namespace, methodName, paramNames, paramValues);


Note: The SOAPRequestObject class has a method called addParameterAsXML that allows you to pass complex XML documents as parameters.

Controlling the XML Output of the SOAP Response


By default, if you use the execute method to run the SOAP request, the SOAP response will be embedded in the tuple/old and the methodname tags. If you do not want the response to be embedded in these tags, ensure that your Java class implements the com.eibus.applicationconnector.java.Tupable interface, or there should be an attribute called wt with valuefalsein the method implementation.

<implementation type="BsfJavaCall">
    <class>bsf.ub.gen.UIOrder</class>
    <method ct="elements" dt="int" scope="out" wt="false">getOrderProduct</method>
    <parameters/>
</implementation>


Note: Ensure that the content type attribute ( ct ) in the implementation has been set to
elements.

Tracking the Requests and Responses


You can build a code in your program to trace the XML Query (XQY) requests and responses and view them on the Admin console.

  • To trace the request, set
    com.cordys.cpc.bsf.query.xqy.XqyUpdateHandler.traceRequest = true;

  • To trace the response, set
    com.cordys.cpc.bsf.query.xqy.XqyUpdateHandler.traceResponse = true;

Related reference

Insert BusObject SOAP Request
Delete BusObject SOAP Request
Update BusObject SOAP Request
Query BusObject SOAP Request
Validate BusObject SOAP Request